const { Controller } = require('egg');
const validate = require('../rule/rule');

class AddressController extends Controller {
  /**
   *
   * @param req
   * @param res
   * @api { GET } /user/address/list 地址列表
   * @apiName list
   * @apiGroup address
   * @apiVersion 1.0.0
   *
   * @apiRequest json
   * @apiQuery { Number } pageIndex 页码
   * @apiQuery { Number } pageSize 页面大小
   * @apiQuery { String } order 排序字段
   * @apiQuery { String } method 排序方式
   *
   * @apiHeader { String } Authorization 注册信息
   *
   */
  async init(req, res) {
    const ctx = this.ctx;
    try {
      const data = ctx.service.home.init();
      ctx.status = 200;
      ctx.sendSuccess({ data });
      return;
    } catch (error) {
      ctx.status = 500;
      ctx.sendFailed({ msg: error.message });
      return;
    }
  }
}

module.exports = AddressController;
